/*
 * 
 * Author: Mishal Parmar
 * Date: 27 Oct 2012
 */
package dbhandler;

import entityclasses.eligibility;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 * @author Mishal Parmar
 * Date 25 Oct 2012
 */
public class EligibilityCheck {
    
    public ArrayList eligibilitychk() throws SQLException
    {
    String Query;
    
    Query="Select * from tbl_eligibility;";
    
    DBConnection db= new DBConnection();
    ArrayList<eligibility> eligiblearr=new ArrayList<eligibility>();
    ResultSet rs;
    
    db.connect();
    try{
        rs=db.customQuery(Query);
        
        while(rs.next())
        {
            eligibility eligible=new eligibility();
            eligible.getCom_id();
            eligible.getCpi();
            eligible.getBacklog();
            eligiblearr.add(eligible);
            
        }
        
    }catch(SQLException e){
        e.printStackTrace();
    }
        
            
    
    
    
    return eligiblearr;
    }
    
    public boolean addeligiblity(eligibility eligbl) throws SQLException
    {
    String Query;
    
    Query="INSERT INTO `tbl_eligibility`(`com_id`, `cpi`, `backlog`) VALUES ("+eligbl.getCom_id()+","+eligbl.getCpi()+","+eligbl.getBacklog()+");";
    
    DBConnection db= new DBConnection();
    ArrayList<eligibility> eligiblearr=new ArrayList<eligibility>();
    ResultSet rs;
    
    db.connect();
    try{
        db.executeQuery(Query);
        
    }catch(SQLException e){
        e.printStackTrace();
    }
        
    
    return true;
    }
    
    public static void main(String [] args){
        try{
            /*eligibilitycheck el=new eligibilitycheck();
            eligibility e=new eligibility();
            e.setBacklog(0);
            e.setCom_id(1);
            e.setCpi(8);
            el.addeligiblity(e);
            */
        }catch(Exception e){
            e.printStackTrace();
        }
    }
            
}
